﻿using System;
using System.Windows.Forms;

namespace VectorGraph.Common
{
    public class CmdState
    {
        public CmdState()
        {
        }

        #region Fileds
        private CmdState _nextCmd;
        private CmdState _prevCmd;
        #endregion

        #region Protected
        protected void DoCancel()
        {
        }

        protected void DoFinish()
        {
        }

        protected void DoKeyDown(object sender, KeyEventArgs e)
        {
        }

        protected void DoMouseDown(object sender, MouseEventArgs e)
        {
        }

        protected void DoMouseMove(object sender, MouseEventArgs e)
        {
        }

        protected void DoMouseUp(object sender, MouseEventArgs e)
        {
        }

        protected void Initialize()
        {
        }
        #endregion

        #region Public
        /// <summary>
        /// 取消。
        /// </summary>
        public void Cancel()
        {
        }

        /// <summary>
        /// 完成。
        /// </summary>
        public void Finish()
        {

        }

        /// <summary>
        /// 键盘按下事件。
        /// </summary>
        public void KeyDown(object sender, KeyEventArgs e)
        {
            if (_nextCmd != null)
            {
                _nextCmd.KeyDown(sender, e);
            }
            else
            {
                DoKeyDown(sender, e);
            }
        }

        /// <summary>
        /// 鼠标按下事件。
        /// </summary>
        public void MouseDown(object sender, MouseEventArgs e)
        {
            if (_nextCmd != null)
            {
                _nextCmd.MouseDown(sender, e);
            }
            else
            {
                DoMouseDown(sender, e);
            }
        }

        /// <summary>
        /// 鼠标移动事件。
        /// </summary>
        public void MouseMove(object sender, MouseEventArgs e)
        {
            if (_nextCmd != null)
            {
                _nextCmd.MouseMove(sender, e);
            }
            else
            {
                DoMouseMove(sender, e);
            }
        }

        /// <summary>
        /// 鼠标弹起事件。
        /// </summary>
        public void MouseUp(object sender, MouseEventArgs e)
        {
            if (_nextCmd != null)
            {
                _nextCmd.MouseUp(sender, e);
            }
            else
            {
                DoMouseUp(sender, e);
            }
        }
        #endregion
    }
}